package com.lkk.testcase;

import java.util.ArrayList;

import org.testng.Assert;
import org.testng.Reporter;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lkk.data.Log;
import com.lkk.util.CommonUtil;

public class apiTest3 extends CaseSuper{
	//指定测试用例
	String caseNum1 = "xxx-1";
	String caseNum2 = "xxx-2";
	
	@BeforeClass
	public void startCaseClass() {
		Log.startTestCase();
	}
	
	@BeforeMethod
	public void startCase() {
		caseNumList.add(caseNum1);
		caseNumList.add(caseNum2);
	}
	@Test(priority = 2)
	public void case3(){
		//获取请求实体对象
		getExcelDataEntity(caseNumList.get(0));
		//获取参数
		getParam();
		//发送请求
		getResponse(caseNum1);
		//获取断言属性
		String errorMsg = responseBody.getString("errorMsg");
		
		Assert.assertEquals(errorMsg,assertions.get("errorMsg"));
		Assert.assertEquals(Integer.toString(responseCode),status);
		Log.info("------用例1执行成功-------");
		
		//获取请求实体对象
		getExcelDataEntity(caseNumList.get(1));
		//获取参数
		getParam();
		//设置userId
		body.put("userId", CommonUtil.userId);
		//发送请求
		getResponse(caseNum2);
		String errorMsg1 = responseBody.getString("errorMsg");
		String errorCode = responseBody.getString("errorCode");

		Assert.assertEquals(errorMsg1, assertions.get("errorMsg"));
		Assert.assertEquals(errorCode, assertions.get("errorCode"));
		
		Assert.assertEquals(Integer.toString(responseCode),status);
	}

	@AfterMethod
	public void endCase() {
		Log.endTestCase();
	}

}
